package com.stars.empoly.fragment

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.qmuiteam.qmui.widget.tab.QMUITab
import com.qmuiteam.qmui.widget.tab.QMUITabBuilder
import com.stars.empoly.base.MBTabFragment
import com.stars.empoly.databinding.FragmentHomeOrderBinding
import com.stars.empoly.vmodel.HomeOrderVModel
import com.trailer.base.utils.B

/**
 *on 2022/9/22
 */
class HomeOrderFragment : MBTabFragment<HomeOrderVModel, FragmentHomeOrderBinding>(){


    override fun vmClass(): Class<HomeOrderVModel> {
        return HomeOrderVModel::class.java
    }

    override fun title(): String? {
        return null
    }
    override fun binding(
        inflater: LayoutInflater,
        container: ViewGroup?
    ): FragmentHomeOrderBinding {
       return FragmentHomeOrderBinding.inflate(layoutInflater)
    }



    override fun getPageItem(position: Int): Fragment {
        var ownerFragment = OrderListFragment()
        when (position) {
            0 -> {
                ownerFragment.arguments = B().putString("status", "-1")
                    .ok()
                return ownerFragment
            }
            1 -> {

                ownerFragment.arguments = B().putString("status", "0")
                    .ok()
                return ownerFragment

            }
            2 -> {

                ownerFragment.arguments = B().putString("status", "1")
                    .ok()
                return ownerFragment

            }

            3 -> {

                ownerFragment.arguments = B().putString("status", "2")
                    .ok()
                return ownerFragment

            }

            4 -> {

                ownerFragment.arguments = B().putString("status", "3")
                    .ok()
                return ownerFragment

            }

            else->{

                ownerFragment.arguments = B().putString("status", "-1")
                    .ok()
                return ownerFragment
            }

        }


    }

    override fun getPageCount(): Int {
       return 5
    }

    override fun createTabs(tabBuilder: QMUITabBuilder): Array<QMUITab> {
        val one = tabBuilder
            .setText("全部")
            .build(context())
        val two = tabBuilder
            .setText("待支付")
            .build(context())
        val three = tabBuilder
            .setText("待接单")
            .build(context())
        val four = tabBuilder
            .setText("已接单")
            .build(context())
        val five = tabBuilder
            .setText("已完成")
            .build(context())

        return arrayOf(one, two,three,four,five)
    }
}
